<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">

    <meta name="twitter:site" content="@metroui">
    <meta name="twitter:creator" content="@pimenov_sergey">
    <meta name="twitter:card" content="summary">
    <meta name="twitter:title" content="Metro 4 Components Library">
    <meta name="twitter:description" content="Metro 4 is an open source toolkit for developing with HTML, CSS, and JS. Quickly prototype your ideas or build your entire app with responsive grid system, extensive prebuilt components, and powerful plugins  .">
    <meta name="twitter:image" content="https://metroui.org.ua/images/m4-logo-social.png">

    <meta property="og:url" content="https://metroui.org.ua/v4/index.html">
    <meta property="og:title" content="Metro 4 Components Library">
    <meta property="og:description" content="Metro 4 is an open source toolkit for developing with HTML, CSS, and JS. Quickly prototype your ideas or build your entire app with responsive grid system, extensive prebuilt components, and powerful plugins  .">
    <meta property="og:type" content="website">
    <meta property="og:image" content="https://metroui.org.ua/images/m4-logo-social.png">
    <meta property="og:image:secure_url" content="https://metroui.org.ua/images/m4-logo-social.png">
    <meta property="og:image:type" content="image/png">
    <meta property="og:image:width" content="968">
    <meta property="og:image:height" content="504">

    <meta name="author" content="Sergey Pimenov">
    <meta name="description" content="The most popular HTML, CSS, and JS library in Metro style.">
    <meta name="keywords" content="HTML, CSS, JS, Metro, CSS3, Javascript, HTML5, UI, Library, Web, Development, Framework">

    <link rel="shortcut icon" href="favicon.ico" type="image/x-icon">
    <link rel="icon" href="favicon.ico" type="image/x-icon">

    <link href="metro/css/metro-all.css?ver=@@b-version" rel="stylesheet">
    <link href="highlight/styles/github.css" rel="stylesheet">
    <link href="docsearch/docsearch.min.css" rel="stylesheet">
    <link href="css/site.css" rel="stylesheet">

    <title>AdBlock hunter - Metro 4 :: Popular HTML, CSS and JS library</title>
</head>
<body class="m4-cloak">

<header data-role="html-container" data-insert-mode="replace" data-html-source="header.html"></header>

<div data-role="html-container" data-insert-mode="replace" data-html-source="sidebar-menu.html"></div>

<div class="container-fluid docs-content">

    <div class="row flex-xl-nowrap">

            <div class="d-none d-block-xl cell-xl-2 order-2 border-left bd-light toc-wrapper">
                <h5>Table of contents</h5>
                <hr/>
                <ul class="toc-nav">
                    <li class="toc-entry"><a href="#">AdBlock hunter</a></li>
                </ul>

            </div>

            <main class="cell-xl-10 order-1 pr-1-sx pl-1-sx pr-5-md pl-5-md">
                <div class="place-right d-none d-block-lg" style="width: 200px;">
                    <img src="images/logo.png" class="w-100" alt="">
                </div>

                <h1>AdBlock hunter</h1>
                <p class="text-leader">

                </p>

                <!-- ads-html -->

                <h3>About</h3>
                <div>
                    In version 4.3.7 I'm added new component Adblocker. This component is intended for hunting/fishing for ad blockers.
                </div>

                <h3>Setup</h3>
                <div>The component works automatically. To configure it, you can create a settings object names metroAdblockSetup and put it before Metro 4 js file:</div>

                <pre><code>
                    &lt;script&gt;
                        var metroAdblockSetup = {
                            checkInterval: 5000,
                            fireOnce: 3,
                            onBite: function(){
                                console.warn("Adblock present");
                            }
                        }
                    &lt;/script&gt;
                    &lt;script src="metro.js"&gt;&lt;/script&gt;
                </code></pre>

                <h3>Options</h3>
                <ul>
                    <li><code>checkInterval</code> - ms, How often to check the bite</li>
                    <li><code>checkStop</code> - int, How many times to check a bite before leaving fishing</li>
                    <li><code>fireOnce</code> - bool || int, How many times to generate an event that the blocker is caught</li>
                    <li><code>onBite</code> - event, Callback for an event when a blocker is caught</li>
                </ul>

                <h3>Events</h3>
                <div>
                    Component <code>Adblock</code> firing event <code>adblockalert</code>, when blocker is caught. You can add <code>eventListener</code> to work with it.
                </div>
                <pre><code>
                    $(window).on("adblockalert", function(){
                        ...
                    });
                </code></pre>
                or
                <pre><code>
                    window.addEventListener("adblockalert", function(){
                        ...
                    });
                </code></pre>

                <h3>Example</h3>
                <p>See demo - <a href="https://pimenov.com.ua/demo/adblock/adblock.html">https://pimenov.com.ua/demo/adblock/adblock.html</a>. Below is a full source code for demo.</p>

                <pre><code>
                    &lt;!DOCTYPE html&gt;
                    &lt;html lang="en"&gt;
                    &lt;head&gt;
                        &lt;meta charset="UTF-8"&gt;
                        &lt;meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"&gt;
                        &lt;link href="metro/css/metro-all.css?ver=@@b-version" rel="stylesheet"&gt;

                        &lt;title&gt;AdBlock Alert - Metro 4 :: Popular HTML, CSS and JS library&lt;/title&gt;
                    &lt;/head&gt;
                    &lt;body class="m4-cloak"&gt;
                        &lt;div class="container"&gt;
                            &lt;h1 class="text-center"&gt;AdBlock hunter demo&lt;/h1&gt;
                            &lt;div class="text-center"&gt;
                                If ad blocker is enabled, you should see a toast notification about this. This notification will appear three times.
                            &lt;/div&gt;
                        &lt;/div&gt;

                        &lt;script&gt;
                            var metroAdblockSetup = {
                                checkInterval: 5000,
                                fireOnce: 3,
                                onBite: function(){
                                    console.warn("Adblock present");
                                }
                            }
                        &lt;/script&gt;
                        &lt;script src="metro/js/metro.js?ver=@@b-version"&gt;&lt;/script&gt;
                        &lt;script&gt;
                            $(function(){
                                $(window).on("adblockalert", function(){
                                    Metro.toast.create("AdBlock present", null, null, "alert", {
                                        showTop: true,
                                        distance: 150
                                    });
                                })
                            })
                        &lt;/script&gt;
                    &lt;/body&gt;
                    &lt;/html&gt;
                </code></pre>
            </main>
        </div>

    </div>

    <script src="docsearch/docsearch.min.js"></script>


    <script src="metro/js/metro.js?ver=@@b-version"></script>
    <script src="highlight/highlight.pack.js"></script>
    <script src="js/clipboard.min.js"></script>
    <script src="js/site.js"></script>
    <!-- ads-script -->
    <!-- ga-script -->
    <!-- hit-ua -->
</body>
</html>